﻿<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-header">
            长度单位
        </div>
        <div class="layui-card-body">
            <table id="LAY-dimensions-list" lay-filter="LAY-dimensions-list"></table>
            <script type="text/html" id="layuiadmin-app-cont-tagsbar">
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>@T("Admin.Common.Edit")</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>@T("Admin.Common.Delete")</a>
            </script>
        </div>
    </div>
    <div class="layui-card">
        <div class="layui-card-header">
            重量单位
        </div>
        <div class="layui-card-body">
            <table id="LAY-weights-list" lay-filter="LAY-weights-list"></table>
            <script type="text/html" id="layuiadmin-weights-tagsbar">
                <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>@T("Admin.Common.Edit")</a>
                <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>@T("Admin.Common.Delete")</a>
            </script>
        </div>
    </div>
</div>


<script>

    layui.use(['index','table'], function () {

        var table = layui.table;
        //长度管理
        table.render({
            elem: '#LAY-dimensions-list'
            , url: '@Html.Raw(Url.Action("Dimensions"))' //模拟接口
            ,method:'post'
            , page: true //开启分页
            , even: true
            , limit: 15
            , limits: [15,30,50,100]
            , cols: [[
                { type: 'numbers', fixed: 'left' }
                , { field: 'Id', width: 100, title: 'ID' }
                , { field: 'SystemKeyword', title: '系统关键字', minWidth: 100 }
                , { field: 'Ratio', title: '比例', minWidth: 150 }
                , { title:'@T("Admin.Common.Operate")', width: 150, align: 'center', fixed: 'right', toolbar: '#layuiadmin-app-cont-tagsbar' }
            ]]
            , text: { none: '一条数据也没有^_^' }
        });

        //重量管理
        table.render({
            elem: '#LAY-weights-list'
            , url: '@Html.Raw(Url.Action("Weights"))' //模拟接口
            ,method:'post'
            , page: true //开启分页
            , even: true
            , limit: 15
            , limits: [15,30,50,100]
            , cols: [[
                { type: 'numbers', fixed: 'left' }
                , { field: 'Id', width: 100, title: 'ID' }
                , { field: 'SystemKeyword', title: '系统关键字', minWidth: 100 }
                , { field: 'Ratio', title: '比例', minWidth: 150 }
                , { title:'@T("Admin.Common.Operate")', width: 150, align: 'center', fixed: 'right', toolbar: '#layuiadmin-app-cont-tagsbar' }
            ]]
            , text: { none: '一条数据也没有^_^' }
        });

        //监听工具条
        table.on('tool(LAY-dimensions-list)', function (obj) {
            var data = obj.data;
            if (obj.event === 'del') {
                layer.confirm('@T("Admin.Common.DelConfirm")', function (index) {
                    obj.del();
                    $.post('@Url.Action("DimensionDelete")', { id: obj.data.Id });
                    layer.close(index);
                });
            } else if (obj.event === 'edit') {
                var tr = $(obj.tr);
                var index = layer.open({
                    title: '编辑'
                    , type: 2
                    , shade: 0.2
                    , maxmin: true
                    , shadeClose: true
                    , area: ['100%', '100%']
                    , content: '@Url.Action("Edit")?id=' + data.Id
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            }
        });

        var $ = layui.$, active = {
            add: function () {
                var index = layer.open({
                    title: '编辑'
                    , type: 2
                    , shade: 0.2
                    , maxmin: true
                    , shadeClose: true
                    , area: ['100%', '100%']
                    , content: '@Url.Action("Edit")'
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
                return false;
            }
        }
        $('.layui-btn.layuiadmin-btn-tags').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
</script>






